package org.dromara.web.controller.business;

import java.util.List;

import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import org.dromara.web.domain.vo.RemoveRequest;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.web.core.BaseController;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.excel.utils.ExcelUtil;
import org.dromara.dao.business.domain.ModelParam;
import org.dromara.dao.business.domain.ModelParamQuery;
import org.dromara.web.service.business.ModelParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.dromara.common.mybatis.core.page.TableDataInfo;


/**
 * 文生图模型参数 控制器
 *
 * @date 2025-01-16 10:46:07
 */
@Validated
@RestController
@RequestMapping("/common/modelParam")
public class ModelParamController extends BaseController {

    @Autowired
    private ModelParamService modelParamService;

    /**
     * 查询文生图模型参数列表
     * @SaCheckPermission("common:modelParam:list")
     */

    @GetMapping("/list")
    public TableDataInfo<ModelParam> list(ModelParamQuery query, PageQuery pageQuery) {
        return modelParamService.queryPageList(query, pageQuery);
    }




    /**
     * 获取文生图模型参数详细信息
     *
     * @param id 主键
     * @SaCheckPermission("common:modelParam:query")
     */
    @GetMapping("/info")
    public R<ModelParam> getInfo(@NotNull(message = "主键不能为空")
                                     @RequestParam Long id) {
        return R.ok(modelParamService.queryById(id));
    }

    /**
     * 新增文生图模型参数
     * @SaCheckPermission("common:modelParam}:add")
     */

    @Log(title = "文生图模型参数", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping("/add")
    public R<Void> add( @RequestBody ModelParam entity) {
        modelParamService.insert(entity);
        return R.ok();
    }

    /**
     * 修改文生图模型参数
     * @SaCheckPermission("common:modelParam:edit")
     */

    @Log(title = "文生图模型参数", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PostMapping("/update")
    public R<Void> edit( @RequestBody ModelParam update) {
        modelParamService.updateById(update);
        return R.ok();
    }

    /**
     * 删除文生图模型参数
     *
     * @param req 主键串
     * @SaCheckPermission("common:modelParam:remove")
     */

    @Log(title = "文生图模型参数", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    public R<Void> remove(@RequestBody RemoveRequest req) {
        modelParamService.deleteByIds(req.getIds());
        return R.ok();
    }
}
